local HeroDataHelper = {}

-- 获取武将特性
function HeroDataHelper.getHeroEffect(unit, result)
    local config = unit:getConfig()
    local level = unit:getLevel()
    local effectIds = string.split(config.effectId, "|")
    local effectUnlocks = string.split(config.effect_unlock, "|")
    for i = 1, #effectIds do
        local effectId = tonumber(effectIds[i])
        local unlockLevel = tonumber(effectUnlocks[i])
        if level >= unlockLevel then
            table.insert(result, effectId)
        end
    end
end

function HeroDataHelper.getHeroUnitAttr(unit)
    local AttributeConst = require("const.AttributeConst")
    local hero_lvup = require("config.hero_lvup")
    local config = unit:getConfig()
    local lvId = config.lvId
    local level = unit:getLevel()
    local result = {}
    result[AttributeConst.BLOOD] = 0
    result[AttributeConst.ATTACK] = 0
    result[AttributeConst.DEFENSE] = 0
    for i = 1, level do
        local cfg = hero_lvup.get(lvId, i)
        result[AttributeConst.BLOOD] = result[AttributeConst.BLOOD] + cfg.hp_add
        result[AttributeConst.ATTACK] = result[AttributeConst.ATTACK] + cfg.atk_add
        result[AttributeConst.DEFENSE] = result[AttributeConst.DEFENSE] + cfg.def_add
    end
    return result
end

function HeroDataHelper.getHeroCurMaxExp(unit)
    local level = unit:getLevel()
    local nextlevel = level + 1
    local config = unit:getConfig()
    if nextlevel >= config.lv_max then
        nextlevel = config.lv_max
    end
    local cfg = require("config.hero_lvup").get(config.lvId, nextlevel)
    return cfg.exp
end

function HeroDataHelper.getHeroAllAttr(unit)
end

return HeroDataHelper
